home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / telecomm / fnordadl / fn132src.zoo / citutil / clog.c < prev    next >
C/C++ Source or Header  |  1991-09-02  |  3KB  |  134 lines

  1. /*
  2.  * clog.c -- display information about the Fnordadel userlog.
  3.  * 
  4.  * 90Dec07 AA    Hacked a bit for gcc port
  5.  * 88Nov16 orc    change field order around, clean up option parsing
  6.  * 88Jan30 orc    -t flag for constructing userlists
  7.  * 87Aug16 orc    Some hacks for v3.1
  8.  * 87Mar28 orc    changes for major release.
  9.  * 87Mar02 orc    -a flag put in to find illegal aides.
  10.  * 87Mar01 orc    rewritten for the ST.
  11.  */
  12.  
  13. #include "ctdl.h"
  14. #include "log.h"
  15. #include "config.h"
  16. #include "citlib.h"
  17.  
  18. char *program = "clog";
  19. int logfl;
  20. int findnorm = YES;
  21. int passwd = NO;
  22. int tabled = NO;
  23. int showall = NO;
  24. int sorttime = NO;
  25.  
  26. #define MAXUSERS 100
  27. char *users[MAXUSERS];
  28.  
  29. int usercount = 0, seen = 0, txp = 0;
  30.  
  31. static void
  32. showlog(int i)
  33. {
  34.     register int j;
  35.  
  36.     if (tabled) {
  37.     txp = (1 + txp) % 3;
  38.     printf(txp ? "%-25.25s" : "%s\n", logBuf.lbname);
  39.     }
  40.     else if (findnorm || readbit(logBuf,uAIDE)) {
  41.     seen++;
  42.     printf("%4d%c ",i, readbit(logBuf,uINUSE) ? ':' : '!');
  43.     if (showall) {
  44.         for (j=0; j < NAMESIZE; j++)
  45.         putchar(isprint(logBuf.lbname[j]) ? logBuf.lbname[j] : '?');
  46.     }
  47.     else
  48.         printf("%-20.20s", logBuf.lbname);
  49.  
  50.     if (passwd)
  51.         printf(" %-20.20s", logBuf.lbpw);
  52.     printf(" %s", makedate(logBuf.lblast, NO));
  53.     if readbit(logBuf,uSYSOP)
  54.         printf(", Sys");
  55.     else if readbit(logBuf,uAIDE)
  56.         printf(", Aid");
  57.     if readbit(logBuf,uEXPERT)
  58.         printf(", Exp");
  59.     if readbit(logBuf,uNETPRIVS)
  60.         printf(", Net");
  61.     if (!readbit(logBuf,uMAILPRIV))
  62.         printf(", No-Mail");
  63.     if (!readbit(logBuf,uDOORPRIV))
  64.         printf(", No-Door");
  65.     if readbit(logBuf,uTWIT)
  66.         printf(", TWT");
  67.     putchar('\n');
  68.     }
  69. }
  70.  
  71. int
  72. main(int argc, char **argv)
  73. {
  74.     int i, j, entry;
  75.     char *p;
  76.     int pos;
  77.     PATHBUF fn;
  78.     extern char VERSION[];
  79.  
  80. #if 0
  81.     setbuf(stdout, NULL);    /* Avoid stdout buffering */
  82. #endif
  83.  
  84.     printf("%s for Fnordadel V%s\n", program, VERSION);
  85.     
  86.     while (argc > 1) {
  87.     --argc, ++argv;
  88.     p = *argv;
  89.     if (*p == '-') {
  90.         while (*++p)
  91.         switch (toupper(*p)) {
  92.         case 'A': findnorm = NO;    break;
  93.         case 'T': tabled   = YES;    break;
  94.         case 'P': passwd   = YES;    break;
  95.         case 'C': showall  = YES;    break;
  96.         case 'O': sorttime = YES;    break;
  97.         }
  98.     }
  99.     else if (usercount < MAXUSERS)
  100.         users[usercount++] = p;
  101.     }
  102.  
  103.     if (readSysTab(NO)) {
  104.     initlogBuf(&logBuf);
  105.  
  106.     ctdlfile(fn, cfg.sysdir, "ctdllog.sys");
  107.     if ((logfl = dopen(fn, O_RDONLY)) < 0)
  108.         crashout("Can't open %s", fn);
  109.  
  110.     for (i = 0; i < cfg.logsize; i++) {
  111.         pos = sorttime ? logTab[i].ltlogSlot : i;
  112.         getlog(&logBuf, pos, logfl);
  113.         if (showall || readbit(logBuf,uINUSE)) {
  114.         entry++;
  115.         for (j = 0; j < usercount; j++)
  116.             if (labelcmp(logBuf.lbname, users[j]) == 0)
  117.             break;
  118.         if (usercount == 0 || j < usercount)
  119.             showlog(pos);
  120.         }
  121.     }
  122.  
  123.     if (tabled && txp)
  124.         putchar('\n');
  125.     else
  126.         printf("%d/%d user%s, %d log entries\n", seen, entry,
  127.         (entry != 1) ? "s" : "", cfg.logsize);
  128.  
  129.     killlogBuf(&logBuf);
  130.     }
  131.     if (fromdesk())
  132.     hitkey();
  133. }
  134.